$(function(){

	//初始化选中的orderStatus按钮背景色
	$(".cl>span>a").each(function(index,domEle){
		var orderStatus=$("#orderStatus").val();
		var statusArr=["","ORDER_STATUS_CHECKING","ORDER_STATUS_PAYING","ORDER_STATUS_TICKETING","ORDER_STATUS_TICKETED","ORDER_STATUS_REFUSED","ORDER_STATUS_INVALIDING","ORDER_STATUS_CHANGING","ORDER_STATUS_REFUNDING"];
			if(orderStatus==statusArr[index]){
				$(domEle).css({"background-color":"#006090","border-color":"#006090"});
			}	
	});
	
	
	//点击查询按钮提交表单
	$("#findButton").click(function(){
		$("#orderStatus").val($("#orderStatusTemp").val());
		$("#pageIndex").val(0);
		$('#form').submit();
	});
	
	//改变订单来源提交表单
	$("#platform").change(function(){
		$("#pageIndex").val(0);
		$('#form').submit();
	});
	
	//给带有属性[data-toggle='tooltip']的标签注册事件
	//查看备注的插件调用show.bs.tooltip mouseenter options
	$(".table_native_policy").on("mouseenter","[data-toggle='tooltip']",function(){
		$(this).tooltip({html:true});
		$(this).tooltip('show');
		
	});
});
function submitStatus(orderStatus){
	$("#orderStatus").val(orderStatus);
	$("#pageIndex").val(0);
	$('#form').submit();
}

function policyShow(){
	$("[data-toggle='tooltip']").tooltip({
		html:true
	});
}

//选择政策
function select_Commision(title,url,param){
	layer.close();
	var index = layer.open({
		type: 2,
		title: title,
		content: url+param
	});
	layer.full(index);
}

function order_edit(title,url){
		layer.close();
		var index = layer.open({
			type: 2,
			title: title,
			content: url
		});
		layer.full(index);
}

function searchNativePolicy(orderId){
	//alert(JSON.stringify({orderId : orderId,time:new Date()}))
	//"orderId="+orderId
	//{"orderId" : orderId,"time":new Date()}

	$("#native_a_" + orderId).removeAttr("onClick");
	$("#casa_native" + orderId).show();
	$("#native_tbl_" + orderId+" tbody").html("");
	$("#native_tbl_" + orderId+" .policy_head").html("");
	$.ajax({
		type : "post",
		url : "../commisionpolicy/searchNativePolicy",
		//contentType:"application/json;charset=utf-8",
		//dataType:"json",
		data : {"orderId" : orderId,"time":new Date()},
		success : function(data){
			result = jQuery.parseJSON(data);
			if(result.success){
				if(result.obj.showPolicies.length > 0){
					$("#native_tbl_" + orderId)
					.append("<tr class='policy_head'><th width='6%'>政策来源</th>"
							+"<th width='8%'>结算价含税</th>"
							+"<th width='8%'>运价/税收</th>"
							+"<th width='8%'>代理费/奖励</th>"
							+"<th width='14%'>直减/开票费/本地服务费</th>"
							+"<th width='8%'>出票类型</th>"
							+"<th width='8%'>是否换编</th>"
							+"<th width='8%'>出票时间</th>"
							+"<th width='6%'>适用条件</th>"
							+"<th width='6%'>选择</th>"
							+"</tr>");
					
					for (var i = 0; i < result.obj.showPolicies.length; i++) {
						var policy = result.obj.showPolicies[i];
						var memo=policy.memoExt;
						
						var fee = "";
			            var fare = "";
			            var agio = "";
			            var other=""
		            	 if (policy.adtPolicy != null) {
		                     fee += "<img src='../static/eth/images/icons_07.jpg'><span class='colo_cheng f16 mr5  '>" + policy.adtPolicy.totalAmount + "</span><br/>";
		                     fare += policy.adtPolicy.ticketPrice + "/" + policy.adtPolicy.tax + "<br/>";
		                     agio += "<span class='colo_cheng f16 mr5  '>" + policy.adtPolicy.commision + "</span>%/<span class='colo_cheng   f16 mr5'>" + policy.adtPolicy.reward + "</span>%<br/>";
		                     other += "<span class='colo_cheng  '>" + policy.adtPolicy.off + "</span>/" + policy.adtPolicy.ticketingPrice + "/" + 0 + "<br/>";
		                 }
		                 if (policy.chdPolicy != null) {
		                     fee += "<img src='../static/eth/images/icons_05.jpg'><span class='colo_cheng  '>" + policy.chdPolicy.totalAmount + "</span><br/>";
		                     fare += policy.chdPolicy.ticketPrice + "/" + policy.chdPolicy.tax + "<br/>";
		                     agio += "<span class='colo_cheng  f16 mr5 '>" + policy.chdPolicy.commision + "</span>%/<span class='colo_cheng  f16 mr5 '>" + policy.chdPolicy.reward + "</span>%<br/>";
		                     other += "<span class='colo_cheng  '>" + policy.chdPolicy.off + "</span>/" + policy.chdPolicy.ticketingPrice + "/" + 0 + "<br/>";
		                 }
		                 if (policy.infPolicy != null) {
		                     fee += "<img src='../static/eth/images/icons_03.jpg'><span class='colo_cheng  f16 mr5 '>" + policy.infPolicy.totalAmount + "</span><br/>";
		                     fare += policy.infPolicy.ticketPrice + "/" + policy.infPolicy.tax + "<br/>";
		                     agio += "<span class='colo_cheng f16 mr5  '>" + policy.infPolicy .commision + "</span>%/<span class='colo_cheng   f16 mr5'>" +policy.infPolicy .reward + "</span>%<br/>";
		                     other += "<span class='colo_cheng  '>" + policy.infPolicy.off + "</span>/" + policy.infPolicy.ticketingPrice + "/" + 0 + "<br/>";
		                 }	
								
						$("#native_tbl_" + orderId)
						.append("<tr class='policy_content'>"
								+"<td>本地</td>"
								+"<td>"+fee+"</td>"
								+"<td>"+fare+"</td>"
								+"<td>"+agio+"</td>"
								+"<td>"+other+"</td>"
								+"<td><em class='bsp'>" + policy.ticketTypeStr + "</em></td>"
					            +"<td><em class='bsp'>原编出票</em></td>"
								+"<td>"+"08:26-23:59"+"</td>"
					            +"<td class='bsp_a'>"
					            +	"<a href='javascript:void(0)'>查看备注"
					            +		"<div>" + memo + "</div>"
					            +	"</a>"
					            +"</td>"
			//					+"<td>"+"<a href='javascript:'  class='c-primary' data-toggle='tooltip' html='true'  title='"+memo+"' data-placement='bottom'>查看备注</a>"+"</td>"
								+"<td>"+"<a href='javascript:' class='c-primary' onClick=\"select_Commision('订单详情','selectCommision?',"+"'orderId="+result.obj.order.orderId+"&policyIds="+policy.policyIds+"')\">选择政策</a>"+"</td>"
								+"</tr>");
					}
				}else{
					$("#native_tbl_" + orderId)
					.append("<tr class='policy_content'>"
							+"<td colspan='11'>暂无匹配的政策</td>"
							+"</tr>");
				}
				$("#casa_native" + orderId).hide();
				$("#native_tbl_" + orderId).show();
				$("#native_a_" + orderId).attr("onClick","searchNativePolicy("+orderId+");");
			}else{
				$("#native_tbl_" + orderId)
				.append("<tr class='policy_content'>"
						+"<td colspan='11'>暂无匹配的政策</td>"
						+"</tr>");
				$("#casa_native" + orderId).hide();
				$("#native_tbl_" + orderId).show();
				$("#native_a_" + orderId).attr("onClick","searchNativePolicy("+orderId+");");
			}
		},
		error : function(data){
			$("#native_tbl_" + orderId)
			.append("<tr class='policy_content'>"
					+"<td colspan='11'>匹配政策错</td>"
					+"</tr>");
			$("#casa_native" + orderId).hide();
			$("#native_tbl_" + orderId).show();
			$("#native_a_" + orderId).attr("onClick","searchNativePolicy("+orderId+");");
		}
	});
}

function showNativePrice(){
	$.post("/PriceParity/QueryBasicPolicyParity", data, function (msg) {
        msg = eval("(" + msg + ")");
        if (msg.Message != "SUCCESS") {
            $("#div_" + orderid).html("无政策匹配");
        }
        else {
            var tr = "         <table class='table mt0'>";
            tr += "                 <tr>";
            tr += "                     <th width='110px'>政策来源</th>";
            tr += "                     <th width='120px'>结算价含税</th>";
            tr += "                     <th width='140px'>运价/税收</th>";
            tr += "                     <th width='140px'>代理费/奖励</th>";
            tr += "                     <th width='150px'>直减/开票费/本地服务费</th>";
            tr += "                     <th width='90px'><select class='w100' id='BasicTicketType" + orderid + "' onChange='Fs.selectBasicPolicies(\"" + orderid + "\")'><option selected value=''>出票类型</option><option value='BSP'>BSP</option><option value='B2B'>B2B</option><option value='境外电子'>境外电子</option></select></th>";
            tr += "                     <th width='90px'><select class='w100' id='BasicIsChange" + orderid + "' onChange='Fs.selectBasicPolicies(\"" + orderid + "\")'><option selected value=''>是否换编</option><option value='换编出票'>换编出票</option><option value='原编出票'>原编出票</option></select></th>";
            tr += "                     <th width='90px'>出票时间</th>";
            tr += "                     <th width='70px'>适用条件</th>";
            tr += "                     <th width='70px'>选择</th>";
            tr += "                 </tr>";
            for (var i = 0; i < msg.ShowPolicies.length; i++) {
                var ischange = msg.ShowPolicies[i].IsTransformCode;
                if (ischange) {
                    ischange = "换编出票";
                } else {
                    ischange = "原编出票";
                }
                var fee = "";
                var fare = "";
                var agio = "";
                var other=""
                var policyinfo = "policyId=" + msg.ShowPolicies[i].PolicyId + "&";
                if (msg.ShowPolicies[i].AdtPolicy != null) {
                    fee += "<img src='/Content/images/icons_07.gif'><span class='colo_cheng f16 mr5  '>" + msg.ShowPolicies[i].AdtPolicy.Price + "</span><br/>";
                    fare += msg.ShowPolicies[i].AdtPolicy.FarePrice + "/" + msg.ShowPolicies[i].AdtPolicy.Tax + "<br/>";
                    agio += "<span class='colo_cheng f16 mr5  '>" + msg.ShowPolicies[i].AdtPolicy.AgencyFee + "</span>%/<span class='colo_cheng   f16 mr5'>" + msg.ShowPolicies[i].AdtPolicy.Agio + "</span>%<br/>";
                    other += "<span class='colo_cheng  '>" + msg.ShowPolicies[i].AdtPolicy.DiscountAmount + "</span>/" + msg.ShowPolicies[i].AdtPolicy.TicketFee + "/" + msg.ShowPolicies[i].AdtPolicy.ServiceFee + "<br/>";
                }
                if (msg.ShowPolicies[i].ChdPolicy != null) {
                    fee += "<img src='/Content/images/icons_05.jpg'><span class='colo_cheng  '>" + msg.ShowPolicies[i].ChdPolicy.Price + "</span><br/>";
                    fare += msg.ShowPolicies[i].ChdPolicy.FarePrice + "/" + msg.ShowPolicies[i].ChdPolicy.Tax + "<br/>";
                    agio += "<span class='colo_cheng  f16 mr5 '>" + msg.ShowPolicies[i].ChdPolicy.AgencyFee + "</span>%/<span class='colo_cheng  f16 mr5 '>" + msg.ShowPolicies[i].ChdPolicy.Agio + "</span>%<br/>";
                    other += "<span class='colo_cheng  '>" + msg.ShowPolicies[i].ChdPolicy.DiscountAmount + "</span>/" + msg.ShowPolicies[i].ChdPolicy.TicketFee + "/" + msg.ShowPolicies[i].ChdPolicy.ServiceFee + "<br/>";
                }
                if (msg.ShowPolicies[i].InfPolicy != null) {
                    fee += "<img src='/Content/images/icons_03.jpg'><span class='colo_cheng  f16 mr5 '>" + msg.ShowPolicies[i].InfPolicy.Price + "</span><br/>";
                    fare += msg.ShowPolicies[i].InfPolicy.FarePrice + "/" + msg.ShowPolicies[i].InfPolicy.Tax + "<br/>";
                    agio += "<span class='colo_cheng f16 mr5  '>" + msg.ShowPolicies[i].InfPolicy.AgencyFee + "</span>%/<span class='colo_cheng   f16 mr5'>" + msg.ShowPolicies[i].InfPolicy.Agio + "</span>%<br/>";
                    other += "<span class='colo_cheng  '>" + msg.ShowPolicies[i].InfPolicy.DiscountAmount + "</span>/" + msg.ShowPolicies[i].InfPolicy.TicketFee + "/" + msg.ShowPolicies[i].InfPolicy.ServiceFee + "<br/>";
                }
                tr += "                 <tr name='basic_policies_tr" + orderid + "' basicticket_type='" + msg.ShowPolicies[i].TicketType + orderid + "' basicischange='" + ischange + orderid + "'>";
                tr += "                     <td>本地" + msg.ShowPolicies[i].Office + (msg.ShowPolicies[i].IsPrivatePolicy == 1 ? "<span class='redfont'>私</span>" : "") + "</td>";
                tr += "                     <td>" + fee + "</td>";
                tr += "                     <td>" + fare + "</td>";
                tr += "                     <td>" + agio + "</td>";
                tr += "                     <td>" + other + "</td>";
                tr += "                     <td><em class='bsp'>" + msg.ShowPolicies[i].TicketType + "</em></td>";
                tr += "                     <td><em class='bsp'>" + ischange + "</em></td>";
                tr += "                     <td>" + msg.ShowPolicies[i].BeOnDuty + "-" + msg.ShowPolicies[i].OffDuty + "</td>";
                tr += "                     <td class='bsp_a'>";
                tr += "                         <a href='#'>查看备注";
                tr += "                             <div>" + msg.ShowPolicies[i].Remark + "</div>";
                tr += "                         </a>";
                tr += "                     </td>";
                tr += "                     <td>";
                if (isota == "true") {
                    tr += "                         <a class='collink' href='javascript:void(0)' onclick='Fs.OtaSelectPolicy(\"" + orderid + "\",\"" + msg.ShowPolicies[i].PolicyId + "\");' >选择政策</a>";
                } else if (isota == "false") {
                    tr += "                         <a class='collink' href='/OrderDetail/BeforeSale?status=" + status + "&orderid=" + orderid + "&" + policyinfo + "'>选择政策</a>";
                }
                tr += "                     </td>";
                tr += "                 </tr>";
            }
            tr += "             </table>";
            $("#div_" + orderid).html(tr);
        }
    });
}

function searchOthersPolicy(nativeOrderId, pnr){
	$("#casa_JinTong" + nativeOrderId).show();
    $("#casa_517NA" + nativeOrderId).show();
    $("#casa_YI8000" + nativeOrderId).show();
    $("#casa_TraFree" + nativeOrderId).show();
    $("#casa_MEIYA" + nativeOrderId).show();
    $("#casa_TRAVELZEN" + nativeOrderId).show();
    $("#casa_TWFLIGHT" + nativeOrderId).show();
    $("#other_tbl_" + nativeOrderId+" tbody").html("");
    $("#others_a_" + nativeOrderId).removeAttr("onClick");
     
    var data = {"pnr" : pnr,"time":new Date(),"random":Math.random()}
    
    $.post("../jinri/createOrder", data, function(msg) {
		result = jQuery.parseJSON(msg);
		if (result.success) {
			showOthersPolicy(nativeOrderId, result.obj, pnr);
//			flag = true;
//			ajaxFinished();
		}else{
			showOthersPolicy(nativeOrderId, "null", pnr);
		}
	}).error(function() {
		 var msg = "{'Message':'SYSTEM_ERROR','系统错误','ShowPolicies':null,'PolicyList':null}";
		 addColumn(msg, nativeOrderId, "");
		 $("#others_a_" + nativeOrderId).attr("onClick","searchOthersPolicy('"+nativeOrderId+"','"+pnr+"');");
	});
}

function showOthersPolicy(nativeOrderId, othersOrderId, pnr){
	var count = 0;
	var finished = function(){
		if(count >= 6){
			 $("#others_a_" + nativeOrderId).attr("onClick","searchOthersPolicy('"+nativeOrderId+"','"+pnr+"');");
		}
	} 
     //运价直连
     var data1 = {
         OrderId: othersOrderId,
         Third: 13, //运价直连
         Random: Math.random()
     };
     $.post("../jinri/othersPolicy", data1, function (msg) {
         addColumn(msg, nativeOrderId, "JinTong");
         count++;
         finished();
     }).error(function () { 
         var msg = "{'Message':'SYSTEM_ERROR','系统错误','ShowPolicies':null,'PolicyList':null}";
         addColumn(msg, nativeOrderId, "JinTong");
         count++;
         finished();
     });

     //517
     var data3 = {
         OrderId: othersOrderId,
         Third: 10, //517
         Random: Math.random()
     };
     $.post("../jinri/othersPolicy", data3, function (msg) {
         addColumn(msg, nativeOrderId, "517NA");
         count++;
         finished();
     }).error(function () {
         var msg = "{'Message':'SYSTEM_ERROR','系统错误','ShowPolicies':null,'PolicyList':null}";
         addColumn(msg, nativeOrderId, "517NA");
         count++;
         finished();
     });

     //8000YI
     var data4 = {
         OrderId: othersOrderId,
         Third: 11, //8000YI
         Random: Math.random()
     };
     $.post("../jinri/othersPolicy", data4, function (msg) {
         addColumn(msg, nativeOrderId, "YI8000");
         count++;
         finished();
     }).error(function () {
         var msg = "{'Message':'SYSTEM_ERROR','系统错误','ShowPolicies':null,'PolicyList':null}";
         addColumn(msg, nativeOrderId, "YI8000");
         count++;
         finished();
     });

     ////TraFree
     //var data5 = {
     //    OrderId: othersOrderId,
     //    Third: 12, //TraFree
     //	   Random: Math.random()
     //};
     //$.post("../jinri/othersPolicy", data5, function (msg) {
     //    addColumn(msg, nativeOrderId, "TraFree");
//     count++;
//     finished();
     //}).error(function () {
     //    var msg = "{'Message':'SYSTEM_ERROR','系统错误','ShowPolicies':null,'PolicyList':null}";
     //    addColumn(msg, nativeOrderId, "TraFree");
//     count++;
//     finished();
     //});
     //美亚
     var data6 = {
         OrderId: othersOrderId,
         Third: 14, //MEIYA
         Random: Math.random()
     };
     $.post("../jinri/othersPolicy", data6, function (msg) {
         addColumn(msg, nativeOrderId, "MEIYA");
         count++;
         finished();
     }).error(function () {
         var msg = "{'Message':'SYSTEM_ERROR','ShowPolicies':null,'PolicyList':null}";
         addColumn(msg, nativeOrderId, "MEIYA");
         count++;
         finished();
     });

     //真旅
     var data6 = {
         OrderId: othersOrderId,
         Third: 15, //TRAVELZEN
         Random: Math.random()
     };
     $.post("../jinri/othersPolicy", data6, function (msg) {
         addColumn(msg, nativeOrderId, "TRAVELZEN");
         count++;
         finished();
     }).error(function () {
         var msg = "{'Message':'SYSTEM_ERROR','ShowPolicies':null,'PolicyList':null}";
         addColumn(msg, nativeOrderId, "TRAVELZEN");
         count++;
         finished();
     });

     //东立
     var data6 = {
         OrderId: othersOrderId,
         Third: 16, //TWFLIGHT
         Random: Math.random()
     };
     $.post("../jinri/othersPolicy", data6, function (msg) {
         addColumn(msg, nativeOrderId, "TWFLIGHT");
         count++;
         finished();
     }).error(function () {
         var msg = "{'Message':'SYSTEM_ERROR','ShowPolicies':null,'PolicyList':null}";
         addColumn(msg, nativeOrderId, "TWFLIGHT");
         count++;
         finished();
     });
}

function addColumn(policies, orderId, title) {
     var msg = eval("(" + policies + ")");
     if (msg.Message == "INVAILD_USERNAME") {
         var errtr = "";
         errtr += "                 <tr>";
         errtr += "                     <td colspan='11' style='color:red;'>" + title + "帐号未绑定</td>";
         errtr += "                 </tr>";
         if (title == "JinTong" || title == "JinTongInt") {
             $("#other_tbl_" + orderId + " tbody.JinTong").append(errtr);
         }
         else {
             $("#other_tbl_" + orderId + " tbody." + title).append(errtr);
         }
     }
     else if (msg.Message != "SUCCESS" || msg.ShowPolicies.length == 0) {
         var errtr = "";
         errtr += "                 <tr>";
         errtr += "                     <td colspan='11' style='color:red;'>" + title + "无匹配数据</td>";
         errtr += "                 </tr>";
         if (title == "JinTong" || title == "JinTongInt") {
             $("#other_tbl_" + orderId + " tbody.JinTong").append(errtr);
         }
         else {
             $("#other_tbl_" + orderId + " tbody." + title).append(errtr);
         }
     } else {
         //show                

         for (var i = 0; i < msg.ShowPolicies.length; i++) {
             var show_tr = "";
             var show_rowcount = msg.ShowPolicies.length;
             var show_fee = "";
             var show_fare = "";
             var show_agio = "";
             var show_other = "";
             var show_ischange = msg.ShowPolicies[i].IsTransformCode;
             if (show_ischange) {
                 show_ischange = "换编出票";
             } else {
                 show_ischange = "原编出票";
             }
             if (msg.ShowPolicies[i].AdtPolicy != null) {
                 show_fee += "<img src='../static/eth/images/icons_07.jpg'><span class='colo_cheng f16 mr5'>" + msg.ShowPolicies[i].AdtPolicy.Price + "</span><br/>";
                 show_fare += msg.ShowPolicies[i].AdtPolicy.FarePrice + "/" + msg.ShowPolicies[i].AdtPolicy.Tax + "<br/>";
                 show_agio += "<span class='colo_cheng f16 mr5'>" + msg.ShowPolicies[i].AdtPolicy.AgencyFee + "</span>%/<span class='colo_cheng f16 mr5 '>" + msg.ShowPolicies[i].AdtPolicy.Agio + "</span>%<br/>";
                 show_other += "<span class='colo_cheng'>" + msg.ShowPolicies[i].AdtPolicy.DiscountAmount + "</span>/" + msg.ShowPolicies[i].AdtPolicy.TicketFee + "<br/>";
             }
             if (msg.ShowPolicies[i].ChdPolicy != null) {
                 show_fee += "<img src='../static/eth/images/icons_05.jpg'><span class='colo_cheng  f16 mr5'>" + msg.ShowPolicies[i].ChdPolicy.Price + "</span><br/>";
                 show_fare += msg.ShowPolicies[i].ChdPolicy.FarePrice + "/" + msg.ShowPolicies[i].ChdPolicy.Tax + "<br/>";
                 show_agio += "<span class='colo_cheng  f16 mr5'>" + msg.ShowPolicies[i].ChdPolicy.AgencyFee + "</span>%/<span class='colo_cheng '>" + msg.ShowPolicies[i].ChdPolicy.Agio + "</span>%<br/>";
                 show_other += "<span class='colo_cheng '>" + msg.ShowPolicies[i].ChdPolicy.DiscountAmount + "</span>/" + msg.ShowPolicies[i].ChdPolicy.TicketFee + "<br/>";
             }
             if (msg.ShowPolicies[i].InfPolicy != null) {
                 show_fee += "<img src='../static/eth/images/icons_03.jpg'><span class='colo_cheng f16 mr5 '>" + msg.ShowPolicies[i].InfPolicy.Price + "</span><br/>";
                 show_fare += msg.ShowPolicies[i].InfPolicy.FarePrice + "/" + msg.ShowPolicies[i].InfPolicy.Tax + "<br/>";
                 show_agio += "<span class='colo_cheng  f16 mr5'>" + msg.ShowPolicies[i].InfPolicy.AgencyFee + "</span>%/<span class='colo_cheng '>" + msg.ShowPolicies[i].InfPolicy.Agio + "</span>%<br/>";
                 show_other += "<span class='colo_cheng '>" + msg.ShowPolicies[i].InfPolicy.DiscountAmount + "</span>/" + msg.ShowPolicies[i].InfPolicy.TicketFee +  "<br/>";
             }
             show_tr += "                 <tr fromkey='tr_" + msg.ShowPolicies[i].PolicyFrom + "' showkey='other_show_" + msg.ShowPolicies[i].PolicyFrom + "_" + orderId + "'>";
             show_tr += "                     <td>" + msg.ShowPolicies[i].PolicyFrom + (msg.ShowPolicies[i].IsPrivatePolicy == 1 ? "<span class='redfont'>私</span>" : "") + "</td>";
             show_tr += "                     <td>" + show_fee + "</td>";
             show_tr += "                     <td>" + show_fare + "</td>";
             show_tr += "                     <td>" + show_agio + "</td>";
             show_tr += "                     <td>" + show_other + "</td>";
             show_tr += "                     <td><em class='bsp'>" + msg.ShowPolicies[i].TicketType + "</em></td>";
             show_tr += "                     <td><em class='bsp'>" + show_ischange + "</em></td>";
             show_tr += "                     <td>" + msg.ShowPolicies[i].BeOnDuty + "-" + msg.ShowPolicies[i].OffDuty + "</td>";
             show_tr += "                     <td class='bsp_a'>";
             show_tr += "                         <a href='javascript:void(0)'>查看备注";
             show_tr += "                             <div>" + msg.ShowPolicies[i].Remark + "</div>";
             show_tr += "                         </a>";
             show_tr += "                     </td>";
             if (title == "JinTong" || title == "JinTongInt") {
                 show_tr += "                     <td><a class='collink c-primary' href='javascript:void(0)' onclick=\"Fs.CreateJtOrder('" + msg.ShowPolicies[i].PolicyBasicId + "','" + msg.ShowPolicies[i].Office + "','" + msg.ShowPolicies[i].ED + "','" + orderId + "','')\">下单</a></td>";
             } else {
                 show_tr += "      <td></td>";
             }
             if (i == 0) {
                 show_tr += "                     <td rowspan='" + show_rowcount + "'>";
                 show_tr += "                          <a class='collink c-primary' href='javascript:void(0)' onclick=\"showMorePolicy('" + msg.ShowPolicies[i].PolicyFrom + "','" + orderId + "')\">更多</a>";
                 show_tr += "                     </td>";
             }
             show_tr += "                 </tr>";
             if (title == "JinTong" || title == "JinTongInt") {
                 $("#other_tbl_" + orderId + " tbody.JinTong").append(show_tr);
             }
             else {
                 $("#other_tbl_" + orderId + " tbody." + title).append(show_tr);
             }
         }
         //hide
         for (var i = 0; i < msg.PolicyList.length; i++) {
             var hid_tr = "";
             var hid_rowcount = msg.PolicyList.length;
             var hid_fee = "";
             var hid_fare = "";
             var hid_agio = "";
             var hid_other = "";
             var hid_ischange = msg.PolicyList[i].IsTransformCode;
             if (hid_ischange) {
                 hid_ischange = "换编出票";
             } else {
                 hid_ischange = "原编出票";
             }
             if (msg.PolicyList[i].AdtPolicy != null) {
                 hid_fee += "<img src='../static/eth/images/icons_07.jpg'><span class='colo_cheng f16 mr5'>" + msg.PolicyList[i].AdtPolicy.Price + "</span><br/>";
                 hid_fare += msg.PolicyList[i].AdtPolicy.FarePrice + "/" + msg.PolicyList[i].AdtPolicy.Tax + "<br/>";
                 hid_agio += "<span class='colo_cheng f16 mr5'>" + msg.PolicyList[i].AdtPolicy.AgencyFee + "%/" + msg.PolicyList[i].AdtPolicy.Agio + "</span>%<br/>";
                 hid_other += "<span class='colo_cheng'>" + msg.PolicyList[i].AdtPolicy.DiscountAmount + "</span>/" + msg.PolicyList[i].AdtPolicy.TicketFee  + "<br/>";
             }
             if (msg.PolicyList[i].ChdPolicy != null) {
                 hid_fee += "<img src='../static/eth/images/icons_05.jpg'><span class='colo_cheng f16 mr5'>" + msg.PolicyList[i].ChdPolicy.Price + "</span><br/>";
                 hid_fare += msg.PolicyList[i].ChdPolicy.FarePrice + "/" + msg.PolicyList[i].ChdPolicy.Tax + "<br/>";
                 hid_agio += "<span class='colo_cheng f16 mr5'>" + msg.PolicyList[i].ChdPolicy.AgencyFee + "%/" + msg.PolicyList[i].ChdPolicy.Agio + "</span>%<br/>";
                 hid_other += "<span class='colo_cheng'>" + msg.PolicyList[i].ChdPolicy.DiscountAmount + "</span>/" + msg.PolicyList[i].ChdPolicy.TicketFee + "<br/>";
             }
             if (msg.PolicyList[i].InfPolicy != null) {
                 hid_fee += "<img src='../static/eth/images/icons_03.jpg'><span class='colo_cheng f16 mr5'>" + msg.PolicyList[i].InfPolicy.Price + "</span><br/>";
                 hid_fare += msg.PolicyList[i].InfPolicy.FarePrice + "/" + msg.PolicyList[i].InfPolicy.Tax + "<br/>";
                 hid_agio += "<span class='colo_cheng f16 mr5'>" + msg.PolicyList[i].InfPolicy.AgencyFee + "%/" + msg.PolicyList[i].InfPolicy.Agio + "</span>%<br/>";
                 hid_other += "<span class='colo_cheng'>" + msg.PolicyList[i].InfPolicy.DiscountAmount + "</span>/" + msg.PolicyList[i].InfPolicy.TicketFee + "<br/>";
             }
             hid_tr += "                 <tr showkey='other_hide_" + msg.PolicyList[i].PolicyFrom + "_" + orderId + "' style='display:none;'>";
             hid_tr += "                     <td>" + msg.PolicyList[i].PolicyFrom + "</td>";
             hid_tr += "                     <td>" + hid_fee + "</td>";
             hid_tr += "                     <td>" + hid_fare + "</td>";
             hid_tr += "                     <td>" + hid_agio + "</td>";
             hid_tr += "                     <td>" + hid_other + "</td>";
             hid_tr += "                     <td><em class='bsp'>" + msg.PolicyList[i].TicketType + "</em></td>";
             hid_tr += "                     <td><em class='bsp'>" + hid_ischange + "</em></td>";
             hid_tr += "                     <td>" + msg.PolicyList[i].BeOnDuty + "-" + msg.PolicyList[i].OffDuty + "</td>";
             hid_tr += "                     <td class='bsp_a'>";
             hid_tr += "                         <a href='javascript:void(0)'>查看备注";
             hid_tr += "                             <div>" + msg.PolicyList[i].Remark + "</div>";
             hid_tr += "                         </a>";
             hid_tr += "                     </td>";
             if (title == "JinTong" || title == "JinTongInt") {                        
                 hid_tr += "                     <td><a class='collink c-primary' href='javascript:void(0)' onclick=\"Fs.CreateJtOrder('" + msg.PolicyList[i].PolicyBasicId + "','" + msg.PolicyList[i].Office + "','" + msg.PolicyList[i].ED + "','" + orderId + "','')\">下单</a></td>";
             } else {
                 hid_tr += "      <td></td>";
             }
             if (i == 0 && title != "JinTongInt") {
                 hid_tr += "                     <td rowspan='" + hid_rowcount + "'>";
                 hid_tr += "                          <a class='collink c-primary' href='javascript:void(0)' onclick=\"closeMorePolicy('" + msg.PolicyList[i].PolicyFrom + "','" + orderId + "')\">关闭</a>";
                 hid_tr += "                     </td>";
             }
             hid_tr += "                 </tr>";
             if (title == "JinTong" || title == "JinTongInt") {
                 $("#other_tbl_" + orderId + " tbody.JinTong").append(hid_tr); //prepend
             }
             else {
                 $("#other_tbl_" + orderId + " tbody." + title).append(hid_tr);
             }
         }
     }
     $("#casa_" + title + orderId).hide();
     $("#other_tbl_" + orderId).show();
 }

function showMorePolicy(from, orderId)
{
    $("[showkey='other_show_" + from + "_" + orderId + "']").each(function () {
        $(this).hide();
    });
    $("[showkey='other_hide_" + from + "_" + orderId + "']").each(function () {
        $(this).show();
    });
}

function closeMorePolicy(from, orderId) {
    $("[showkey='other_show_" + from + "_" + orderId + "']").each(function () {
        $(this).show();
    });
    $("[showkey='other_hide_" + from + "_" + orderId + "']").each(function () {
        $(this).hide();
    });
}
